package tienmanh.gs.goldminer.sprite;

import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.PathModifier;
import org.andengine.entity.modifier.SequenceEntityModifier;
import org.andengine.entity.modifier.IEntityModifier.IEntityModifierListener;
import org.andengine.opengl.texture.region.ITiledTextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.modifier.IModifier;

import tienmanh.gs.goldminer.scene.GameScene;

public class Barie extends Object{

	@Override
	protected void onManagedUpdate(float pSecondsElapsed) {
		// TODO Auto-generated method stub
		super.onManagedUpdate(pSecondsElapsed);
		if(!GameScene.isFrzee && !isCheckMouseRun){
			if(end1 > start1)
				if(getX() > end1 || getX() < start1 ){
					speed = -speed;
				}
				if(end1 < start1){
					if(getX() < end1 || getX() > start1 ){
						speed = -speed;
					}	
				}
			setPosition(getX()+speed, getY());
			
		}
	}
	public Barie(float pX, float pY, float pWidth, float pHeight,
			ITiledTextureRegion pTiledTextureRegion,
			VertexBufferObjectManager pVertexBufferObjectManager, int paramInt,
			float paramFloat5, String paramString , float angle) {
		super(pX, pY, pWidth, pHeight, pTiledTextureRegion, pVertexBufferObjectManager,
				paramInt, paramFloat5, paramString);
		// TODO Auto-generated constructor stub
//		setRotationCenter(getWidth()/2, 0);
		setRotation(angle);
	}
	private  boolean isCheckMouseRun;
	public float start1,start2,end1,end2,speed;
	private  boolean isHuong;
	private SequenceEntityModifier lemRun;
	 public void Run(final float paramFloat1, final float paramFloat2, final float paramFloat3, final float paramFloat4, final float paramFloat5)
	  {
		 end1 = paramFloat3;
		 end2 = paramFloat4;
		 speed = paramFloat5;
		 start1 = paramFloat1;
		 start2 = paramFloat2;
	  }
	 public void unPigRun()
	  {
	    unregisterEntityModifier(this.lemRun);
	  }
}
